package com.example.xiaodu.yuejian12.Activity;

import android.app.Activity;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.xiaodu.yuejian12.Bean.ActivityBean;
import com.example.xiaodu.yuejian12.Bean.ShowBean;
import com.example.xiaodu.yuejian12.Listener.RetrofitListener;
import com.example.xiaodu.yuejian12.Model.UserModel;
import com.example.xiaodu.yuejian12.R;
import com.squareup.picasso.Picasso;

public class ShowDetailActivity extends AppCompatActivity {
    private TextView showTime,showTitle;
    private ImageView imageView;
    private UserModel userModel;
    private RetrofitListener<ShowBean> listener;

    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.show_detail);

        initView();
        initListener();
        getData();
    }

    public void initView(){
        imageView=(ImageView)findViewById(R.id.show_picture);
        showTime=(TextView)findViewById(R.id.time);
        showTitle=(TextView)findViewById(R.id.title);


    }

    public void initListener(){
        listener=new RetrofitListener<ShowBean>() {
            @Override
            public void onSuccess(ShowBean showBean) {
                showTime.setText(showBean.getStime());
                showTitle.setText(showBean.getTitle());

                Picasso.with(imageView.getContext()).load("http://10.0.2.2/yuejian/public/static/show/"+showBean.getSpicture()).into(imageView);

            }

            @Override
            public void onFail(String msg) {

            }
        };
    }

    public void getData(){
        userModel=new UserModel();
        userModel.getShowDetail(getIntent().getIntExtra("showID",1),listener);
    }
}

